/*
 * IsStipulation.java
 *
 * Created on October 26, 2005, 10:26 AM
 *
 * To change this basis, choose Tools | Options and locate the basis under
 * the Source Creation and Management node. Right-click the basis and choose
 * Open. You can then make changes to the basis in the Source Editor.
 */

package com.xucia.jsponic.data;

import java.util.Map;
import java.util.TreeMap;

/**
 *
 * @author Kris Zyp
 */
public class IsStipulation implements Stipulation {

    public static Stipulation createStipulation(String str) {
        //TODO: This needs to be created
        throw new RuntimeException("not implemented yet");
    }

    /** Creates a new instance of SimpleStipulation */
    public IsStipulation() {
    }

    public IsStipulation(Object value) {
        this.value = value;
    }
    Object value;
    public Object getValue() {
        return value;
    }
    public void setValue(Object value) {
        //if (this.value != null)
          //  System.err.println("immutable ojbect??");
        this.value = value;
    }

    public boolean qualifies(Object obj) {
       // System.err.println("IsStipulation.qualifies " + obj + " = " + value + " ? " + (obj == value));
        return obj == value;
    }
    @Override
	public String toString() {
        return "@=" + value;
    }

    public Map getNameValueMap() {
        System.err.println(" Warning!!! we are adding a IsStipluation which should not populate throuhg maps, but by setting itself to the new item in the list");
        Map nameValueMap = new TreeMap();
        return nameValueMap;
    }

    public void addToNameValueMap(Map map) {
    }

    @Override
	public IsStipulation clone() {
        try {
            return (IsStipulation) super.clone();
        }
        catch (CloneNotSupportedException e) {
            throw new RuntimeException(e);
        }
    }
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof IsStipulation) {
			return (((IsStipulation)obj).value.equals(value));				
		}
		return false;
	}
	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		return value.hashCode() + 324;
	}


}
